package com.ele.web;

import com.ele.pojo.Business;
import com.ele.pojo.ResponseData;
import com.ele.service.BusinessService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@Tag(name="店铺列表",description = "外卖系统的app接口文档")
public class BusinessController {
    @Resource
    private BusinessService businessService;

    @GetMapping("/businessList")
    @Operation(summary = "查询推荐店铺",description = "返回推荐的店铺数据信息")
    @Parameter(name = "currentPage",description = "当前页码")
    @Parameter(name = "pageSize",description = "每页显示的记录数")
    @ApiResponse(responseCode = "返回列表数据",content = {
            @Content(
                    mediaType = "application/json",
                    schema = @Schema(implementation = ResponseData.class)
            )
    })
    public ResponseData<Business> getBusinessList(
            @RequestParam(name = "currentPage",required = true, defaultValue = "1") Integer currentPage,
            @RequestParam(name = "pageSize",required = true, defaultValue = "6") Integer pageSize){
        return this.businessService.getBusinessList(currentPage,pageSize);
    }

    @GetMapping("/getBusinessInfoList")
    @Operation(summary = "查询店铺", description = "返回店铺数据信息")
    @Parameter(name = "currentPage",description = "分页参数：当前页码")
    @Parameter(name = "pageSize",description = "分页参数：每页展示数据行数")
    @ApiResponse(description = "返回列表数据",content = {
            @Content(
                    mediaType="application/json",
                    schema= @Schema(implementation = ResponseData.class)
            )
    })
    public ResponseData<Business> getBusinessInfoList(
            @RequestParam(name="currentPage" , required = true ,defaultValue = "1") Integer currentPage,
            @RequestParam(name="pageSize" , required = true ,defaultValue = "10")  Integer pageSize ){
        return this.businessService.getBusinessInfoList(currentPage,pageSize);
    }
}